package com.ld.admin.controller.oa;

import javax.validation.Valid;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.ld.admin.controller.AdminBasicController;
import com.ld.admin.model.oa.OaTechstackTagsModel;
import org.springframework.beans.factory.annotation.Autowired;
import com.ld.admin.service.oa.OaTechstackTagsService;
import com.ld.shieldsb.common.core.model.Result;
import com.ld.shieldsb.common.web.util.Web;
import com.ld.shieldsb.dao.model.QueryModel;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * 
 * 技术栈标签云
 * 
 * @ClassName OaTechstackTagsController
 * @author <a href="mailto:donggongai@126.com" target="_blank">吕凯</a>
 * @date 2019年07月15日 11:52:58
 *
 */
@Api(tags = "技术栈标签云")
@Controller(value = "oaOaTechstackTagsController")
@RequestMapping("${shieldsb.adminPath}/oa/techstack")
public class OaTechstackTagsController extends AdminBasicController<OaTechstackTagsModel> {
    @Autowired
    protected OaTechstackTagsService oaTechstackTagsService;

    @ApiOperation(value = "首页", notes = "")
    @RequestMapping(path = "", method = RequestMethod.GET)
    public String index() {
        return "forward:" + adminPath + "/oa/techstack/toSearch"; // 跳转搜索页面
    }

    @ApiOperation(value = "到搜索页面", notes = "")
    @RequestMapping(path = "/toSearch", method = RequestMethod.GET)
    public String toSearch() {
        return "a/oa/techstack/oatechstacktags_search";
    }

    @ApiOperation(value = "搜索结果", notes = "")
    @RequestMapping(path = "/search", method = RequestMethod.POST)
    public String search() {
        QueryModel queryModel = oaTechstackTagsService.getSearchQueryModel(request);
        oaTechstackTagsService.getPageBean(request, getModelClass(), queryModel);
        return "a/oa/techstack/oatechstacktags_list";
    }

    @ApiOperation(value = "技术栈标签云展示", notes = "")
    @RequestMapping(path = "/show", method = RequestMethod.GET)
    public String show() {
        long id = getLong("id");
        oaTechstackTagsService.getOne(request, getModelClass(), id);
        return "a/oa/techstack/oatechstacktags_show";
    }

    @ApiOperation(value = "跳转到添加/修改技术栈标签云", notes = "")
    @RequestMapping(path = "/toAddOrUpdate", method = RequestMethod.GET)
    public String toAddOrUpd() {
        long id = getLong("id");
        oaTechstackTagsService.getOne(request, getModelClass(), id);
        return "a/oa/techstack/oatechstacktags_update";
    }

    @ApiOperation(value = "添加/修改技术栈标签云", notes = "")
    @RequestMapping(path = "/addOrUpdate", method = RequestMethod.POST)
    // 返回json格式
    @ResponseBody
    public Object addOrUpd(@Valid OaTechstackTagsModel model) {
        Result result = oaTechstackTagsService.addOrUpdate(model, model.getId() != null);
        return Web.Response.result(result);
    }
    
    @ApiOperation(value = "删除技术栈标签云", notes = "")
    @RequestMapping(path = "/del", method = RequestMethod.POST)
    // 返回json格式
    @ResponseBody
    public Object del() {
        long id = getLong("id");
        Result result = oaTechstackTagsService.remove(getModelClass(), id);
        return Web.Response.result(result);
    }

}